package com.haixiaoke.saas.repository.util.Tree;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

@Data
public class Node implements Serializable {
    protected Long value;
    protected String label;
    protected Long parentId;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    protected List<Node> children;
    protected Integer level;
    protected String type;

    public Node addChild(Node node) {
        if (children == null) {
            this.children = new LinkedList<>();
        }
        children.add(node);
        return this;
    }

}
